/********************************************************************************
 *      Copyright:  (C) 2022 SCEUC
 *                  All rights reserved.
 *
 *       Filename:  eLoRa.h
 *    Description:  This head file used for tlv
 *
 *        Version:  1.0.0(2022年07月22日)
 *         Author:  Zhang.Kang <13874854275@163.com>
 *      ChangeLog:  1, Release initial version on "2022年07月22日 15时52分43秒"
 *                 
 ********************************************************************************/

#ifndef _ELORA_H_
#define _ELORA_H_

#include <stdint.h>
#include "mosquitto.h"

#define HOST_LEN 64
#define USERNAME_LEN 20
#define PASSWD_LEN 20
#define NETWORK_SIZE 20

typedef struct mqtt_pack_s
{
    int      netaddr;
    int      devaddr;
    int      battery;
    int      devtype;
    float    rssi;
    char     time[24];
    char     temp[10];
    char     humi[10];
}mqtt_pack_t;

typedef struct mqtt_broker_s
{
    char host[HOST_LEN];
    int  port;
    int  keepalive;
    char username[USERNAME_LEN];
    char password[PASSWD_LEN];
    int  network[NETWORK_SIZE];
    int  network_size;
    char header;
    char *json_p;

}mqtt_broker_t;

char *mqtt_pack_json(mqtt_pack_t *p);
int parse_sLoRa(mqtt_pack_t *ep,uint8_t *sp);
int parse_broker_configuration(const char *path,mqtt_broker_t *mb);
int mqtt_broker_connect(mqtt_broker_t mb,struct mosquitto **mosq);
int judge_network(int *arr,int size,int e);

#endif
